﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Project.Domain.AggregateModels;
using System;
using System.Collections.Generic;
using System.Text;

namespace Project.Infrastructure.Models.Mapping
{
    public class ProjectPropertyMap
    : IEntityTypeConfiguration<ProjectProperty>
    {
        public void Configure(EntityTypeBuilder<ProjectProperty> builder)
        {
            //Table.
            builder.ToTable("ProjectProperty");
            //Key.
            builder.HasKey(t => new { t.ProjectId, t.Key, t.Value });
            //Properties.
            builder.Property(t => t.ProjectId)
                .HasColumnName("ProjectId")
                .IsRequired();
            builder.Property(t => t.Text)
               .HasColumnName("Text")
               .HasMaxLength(20)
               .IsUnicode(true)
               .IsRequired();
            builder.Property(t => t.Key)
               .HasColumnName("Key")
               .HasMaxLength(20)
               .IsRequired();
            builder.Property(t => t.Value)
               .HasColumnName("Value")
               .HasMaxLength(20)
               .IsRequired();
            //Relations
        }
    }
}
